package com.telenav.app;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.telenav.framework.mvc.IMvcUiThreadHelper;
import com.telenav.framework.mvc.MvcContext;
import com.telenav.ui.AndroidActivity;
import com.telenav.ui.AndroidUiHelper;

public class TeleNav extends AndroidActivity implements IMvcUiThreadHelper, IApplication{
	
	private boolean isStarted = false;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (isStarted)
        {
            return;
        }
        
        AndroidUiHelper.getInstance().init(this);
        
        View fullView = new LinearLayout(this);
        fullView.setBackgroundColor(0xFFFFFFFF);
        this.setContentView(fullView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
    }
    
    public void onStart()
    {
        super.onStart();
        if (!isStarted)
        {
            isStarted = true;
            startApp();
        }
    }
    
    private void startApp()
    {
    	MvcContext.getInstance().init(this);
    	
    	TeleNavDelegate.getInstance().startApp(null, this);
    }

	@Override
	public void runInUiThread(Runnable run) {
		this.runOnUiThread(run);
		
	}

	@Override
	public void exit(Object params, String exitMsg) {
		this.finish();
	}
}